home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8159 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  49 lines

  1. Path: news.iadfw.net!usenet
  2. From: Mark Nelson <markn@airmail.net>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Newbie doesn't understand compiler error
  5. Date: Fri, 01 Mar 1996 19:07:50 -0600
  6. Organization: customer of Internet America
  7. Message-ID: <31379F66.7BA7@airmail.net>
  8. References: <Pine.SUN.3.91.960301153010.11258B-100000@pioneer.uspto.gov>
  9. NNTP-Posting-Host: dal09-27.ppp.iadfw.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  14.  
  15. Max Schubert wrote:
  16. > I have just started to work with two different learning C books.  They
  17. > both have programs to copy and compile as I go along.  Twice I have
  18. > received this error from cc when attempting to compile two separate
  19. > programs on SunOS 4.1.2:
  20. > main( int argv, char *argc[] )  <<- Compiler states "Syntax error at or near
  21. > {                                   word type char."
  22.  
  23. It appears that you are using the portable C compiler, which doesn't support 
  24. this type of function definition.  To get cc to work, you need to change
  25. the function definitions to look like this:
  26.  
  27. main( argc, argv )
  28. int argc;
  29. char *argv[];
  30. {
  31.  
  32. This should be a mechanical process that will only take you a little while
  33. to master.  Unfortunately, it will get you accustomed to an obsolete
  34. idiom.
  35.  
  36. A better idea is to upgrade to a C compiler that supports ANSI. If you have no
  37. money, gcc is a good bet.  
  38.  
  39. Also, it might just be a typo on your part, but the conventional argument
  40. names for main are argc for the integer argument, and argv for the array
  41. of character pointers.  This doesn't have anything to do with your problem,
  42. however.  (I think.)
  43.  
  44. Mark Nelson
  45. http://web2.airmail.net/markn - C programming articles on line
  46.